@model PagedList<duty_entity>
@{
    ViewData["Title"] = "值班管理";
}
@section Scripts{
<script>
    layui.use(['colorpicker'], function(){
        var upload = layui.upload;

        //普通图片上传
        var uploadInst = upload.render({
            elem: '#test-upload-normal'
            ,url: '/v6admin/api/duty_api/import'
            ,accept: 'file' //普通文件
            ,exts: 'xls|xlsx'//excel文件
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                //obj.preview(function(index, file, result){
                //    $('#test-upload-normal-img').attr('src', result); //图片链接（base64）
                //});
                layer.msg('正在导入....');
            }
            ,done: function(res){
                //如果上传失败
                if(res.code == 200) {
                    layer.msg('成功导入' + res.data.success_count + '条');
                    setTimeout("location.reload();", 3000);
                }
                else {
                    layer.msg(res.msg);
                }
                //上传成功
            }
            ,error: function(){
                layer.msg('导入错误');
            }
        });
    });
</script>
}
<div class="layui-card">
    <div class="layui-card-header">
        @ViewData["Title"]
    </div>
    <div class="layui-card-body">
        <a asp-action="create" class="layui-btn layui-btn-normal">添加值班</a>
        <button type="button" class="layui-btn" id="test-upload-normal"><i class="layui-icon"></i>导入Excel</button>
        <table class="layui-table">
            <thead>
                <tr>
                    <th>
                        @Html.DisplayNameFor(model => model.id)
                    </th>
                    <th>
                        @Html.DisplayNameFor(model => model.date)
                    </th>
                    <th>
                        @ViewData["column_B"]
                    </th>
                    <th>
                        @ViewData["column_C"]
                    </th>
                    <th>
                        @ViewData["column_D"]
                    </th>
                    <th>
                        @ViewData["column_E"]
                    </th>
                    <th>
                        @ViewData["column_F"]
                    </th>
                    <th>
                        @ViewData["column_G"]
                    </th>
                    <th>
                        @ViewData["column_H"]
                    </th>
                    @if (ViewData["column_I"] != null)
                    {
                        <th>
                            @ViewData["column_I"]
                        </th>
                    }
                    @if (ViewData["column_J"] != null)
                    {
                        <th>
                            @ViewData["column_J"]
                        </th>
                    }
                    @if (ViewData["column_K"] != null)
                    {
                        <th>
                            @ViewData["column_K"]
                        </th>
                    }
                    @if (ViewData["column_L"] != null)
                    {
                        <th>
                            @ViewData["column_L"]
                        </th>
                    }
                    @if (ViewData["column_M"] != null)
                    {
                        <th>
                            @ViewData["column_M"]
                        </th>
                    }
                    <th></th>
                </tr>
            </thead>
            <tbody>
                @if (Model.Count() == 0)
                {
                    <tr>
                        <td colspan="15" style="text-align: center;">
                            <div class="layui-inline">--没有记录--</div>
                        </td>
                    </tr>
                }
                @foreach (var item in Model)
                {
                    <tr>
                        <td>
                            @Html.DisplayFor(modelItem => item.id)
                        </td>
                        <td>
                            @item.date.ToString("yyyy-MM-dd")
                            <div>@V6.ConvertDateToZHWeek(item.date)</div>
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.column_B)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.column_C)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.column_D)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.column_E)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.column_F)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.column_G)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.column_H)
                        </td>
                        @if (ViewData["column_I"] != null)
                        {
                            <td>
                                @Html.DisplayFor(modelItem => item.column_I)
                            </td>
                        }
                        @if (ViewData["column_J"] != null)
                        {
                            <td>
                                @Html.DisplayFor(modelItem => item.column_J)
                            </td>
                        }
                        @if (ViewData["column_K"] != null)
                        {
                            <td>
                                @Html.DisplayFor(modelItem => item.column_K)
                            </td>
                        }
                        @if (ViewData["column_L"] != null)
                        {
                            <td>
                                @Html.DisplayFor(modelItem => item.column_L)
                            </td>
                        }
                        @if (ViewData["column_M"] != null)
                        {
                            <td>
                                @Html.DisplayFor(modelItem => item.column_M)
                            </td>
                        }
                        <td style="text-align: right;">
                            <a asp-action="edit" asp-route-id="@item.id">修改</a> |
                            <a asp-action="delete" asp-route-id="@item.id" onclick="return confirm('确认删除吗？');">删除</a>
                        </td>
                    </tr>
                }
            </tbody>
        </table>
        <div style="text-align: center;padding: 16px 0 12px 0;">
            <div class="layui-inline">
                @Html.Pager(Model, new PagerOptions
                {
                PageIndexParameterName = "page",
                TagName = "ul",
                CssClass = "pagination",
                CurrentPagerItemTemplate = "<li class=\"page-item active\"><a  class=\"page-link\" href=\"javascript:void(0);\">{0}</a></li>",
                DisabledPagerItemTemplate = "<li class=\"page-item disabled\"><a class=\"page-link\">{0}</a></li>",
                PagerItemTemplate = "<li class=\"page-item\">{0}</li>",
                PagerItemCssClass = "page-link",
                Id = "bootstrappager"
                })
            </div>
        </div>
    </div>
</div>
